package BC79_图像相似度;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int same = 0;
        ArrayList<Integer> arr1 = new ArrayList<>();
        ArrayList<Integer> arr2 = new ArrayList<>();

        for (int i = 0; i < m * n; i++){
            arr1.add(sc.nextInt());
        }
        for (int i = 0; i < m * n; i++){
            arr2.add(sc.nextInt());
        }
        for (int i = 0; i < m * n; i++){
            if (arr1.get(i) == arr2.get(i)){
                same++;
            }
        }
        double result = same * 100.0 / (m * n);
        System.out.printf("%.2f",result);
    }
}
